#!/bin/sh
# *************************************************************************
# File: killNM.sh
# *************************************************************************
# SMF Macros
. /lib/svc/share/smf_include.sh

#########################################################
#                                                       #
#    res_apps1 server related varible declaration       #  
#                                                       #
#########################################################
cargores_site_dir=/afls_res/booking/managed/cargores/site
export cargores_site_dir
cargores_install_name=aa
export cargores_install_name
cargores_env_name=default
export cargores_env_name
cargores_server_mode=container
export cargores_server_mode
cargores_server_type=apps
export cargores_server_type
# ASPECT_VIEWER=-javaagent:/afls_res/booking/managed/cargores/latest/lib/WEB-INF/lib/aspectjweaver-1.6.8.jar
# export ASPECT_VIEWER
# JASPER_OPTIONS="-Djasper.reports.compile.class.path=/afls_res/booking/managed/cargores/latest/lib/WEB-INF/lib/jasperreports-2.0.4.jar:/afls_res/booking/managed/cargores/latest/lib/itext-2.1.5.jar -Djasper.reports.compile.temp=/afls_res/booking/managed/cargores/temp"
# export JASPER_OPTIONS
# JAVA_OPTIONS="-DLogMgr.configFile="/afls_res/booking/managed/cargores/site/aa_site_default.properties" ${ASPECT_VIEWER} ${JASPER_OPTIONS} ${JAVA_OPTIONS}"
# export JAVA_OPTIONS

# User to run as
USERNAME="${ANT_OS_USER}"
# Set user-defined variables.
unset JAVA_VM MEM_ARGS

WL_HOME="${ANT_WL_HOME}"
. "${WL_HOME}/common/bin/commEnv.sh"

NODEMGR_HOME="${ANT_NM_HOME}"
pid_file="${NODEMGR_HOME}/pid"

# If NODEMGR_HOME does not exist, create it
if [ ! -d "${NODEMGR_HOME}" ]; then
  echo ""
  echo "NODEMGR_HOME ${NODEMGR_HOME} does not exist, creating it.."
  mkdir -p "${NODEMGR_HOME}"
fi

LISTEN_ADDRESS="${ANT_NM_IP}"
LISTEN_PORT="${ANT_NM_PORT}"

# Check for JDK
if [ ! -d "${JAVA_HOME}/bin" ]; then
  echo "The JDK wasn't found in directory ${JAVA_HOME}."
  echo "Please edit the startNodeManager.sh script so that the JAVA_HOME"
  echo "variable points to the location of your JDK."
  exit 1

else

if [ "${MEM_ARGS}" = "" ]
then
MEM_ARGS=${ANT_MEM_ARGS}
fi

# set -x
CLASSPATH="${WEBLOGIC_CLASSPATH}${CLASSPATHSEP}${CLASSPATH}${CLASSPATHSEP}${BEA_HOME}"
export CLASSPATH
export PATH


if [ -r $pid_file ]; then
kill `cat $pid_file`
rm $pid_file
fi

exit $SMF_EXIT_OK
